import axios from 'axios'
import {Toast} from 'vant'
//参数,success,failure
export function request(config) {
    //return new Promise((resolve, reject) => {
    //创建axios实例
    const instance = axios.create({
        baseURL: 'http://123.207.32.32:8000',
        timeout: 5000
    })
    //请求拦截器
    instance.interceptors.request.use(config => {
       // console.log(config);
       Toast.loading({
        message: '加载中...',
        forbidClick: true,
        loadingType: 'spinner'
      });
        return config;
    },err => {
        console.log(err);
    });
    //响应拦截器
    instance.interceptors.response.use(res => {
        //console.log(res);
        Toast.clear();
        return res.data
    },err => {
        console.log(err);
    })

    //发送真正的网络请求
    return instance(config);

}
